﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataModel
{
    public class SiteColumnList : List<SiteColumn>
    {

        /// <summary>
        /// Adds the specified new site column.
        /// </summary>
        /// <param name="nSiteColumn">The new site column.</param>
        new public void Add(SiteColumn nSiteColumn)
        {
            if (!Contains(nSiteColumn.InternalName))
            {
                base.Add(nSiteColumn);
            }
        }

        /// <summary>
        /// Determines whether this [contains] [the specified name].
        /// </summary>
        /// <param name="name">The name.</param>
        /// <returns></returns>
        public bool Contains(String name)
        {
            foreach (SiteColumn sc in this)
            {
                if (sc.InternalName == name)
                {
                    return true;
                }
            }
            return false;
        }

        /// <summary>
        /// Gets the site col with the specified name.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <returns>The site column in this list with the specified name.</returns>
        public SiteColumn GetSiteColByName(String name)
        {
            foreach (SiteColumn sc in this)
            {
                if (sc.InternalName == name)
                {
                    return sc;
                }
            }
            return null;
        }

        /// <summary>
        /// Gets the site col with the specified unique identifier.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <returns>The site column in this list with the specified unique identifier.</returns>
        public SiteColumn GetSiteColByGUID(String id)
        {
            foreach (SiteColumn sc in this)
            {
                if (sc.ID == id)
                {
                    return sc;
                }
            }
            return null;
        }
    }
}
